/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LENOVO
 * Date: 2024-08-04
 * Time: 23:28
 */
class FindMaxFromGeneticArray<E extends Comparable<E>>{
    public E comPare(E[] array){
        E max = array[0];
        for (int i = 1; i < array.length; i++) {
            if(max.compareTo(array[i]) < 0){
                max = array[i];
            }
        }
        return max;
    }
}
public class TestGeneric {
    public static void main(String[] args) {
        Integer[] arr  = new Integer[]{1,2,3,4,5,6,7};//用Integer[]而非int[]
        FindMaxFromGeneticArray<Integer> findMax = new FindMaxFromGeneticArray<>();
        int max = findMax.comPare(arr);
        System.out.println(max);
    }
}
